package cn.gcBlock.service.mapper;

import cn.hutool.core.bean.BeanUtil;
import cn.gcBlock.po.Node;
import cn.gcBlock.dto.NodeDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class BlockNodeMapperImpl implements BlockNodeMapper {

    @Override
    public Node toEntity(NodeDTO arg0) {
        if (arg0 == null) {
            return null;
        }
        Node Node = new Node();
        BeanUtil.copyProperties(arg0, Node);
        return Node;
    }

    @Override
    public NodeDTO toDto(Node arg0) {
        if (arg0 == null) {
            return null;
        }
        NodeDTO Node = new NodeDTO();
        BeanUtil.copyProperties(arg0, Node);
        return Node;
    }

    @Override
    public List<Node> toEntity(List<NodeDTO> arg0) {
        if (arg0 == null) {
            return null;
        }

        List<Node> list = new ArrayList<Node>(arg0.size());
        for (NodeDTO documentDTO : arg0) {
            list.add(toEntity(documentDTO));
        }

        return list;
    }

    @Override
    public List<NodeDTO> toDto(List<Node> arg0) {
        if (arg0 == null) {
            return null;
        }

        List<NodeDTO> list = new ArrayList<NodeDTO>(arg0.size());
        for (Node document : arg0) {
            list.add(toDto(document));
        }

        return list;
    }
}
